{{extend 'layout.html'}}
{{if not len(book):}}
<H2> Book was not found!</H2>

{{else:}}

{{myBook = book[0]}}
<H1> {{=myBook.books.title}} (
{{if myBook.books.status == 'Available':}}
<span style="background-color: yellow">
{{else:}}
<span style="background-color: orange">
{{pass}}
{{=myBook.books.status}}
</span>
)</H1>
<BR>
<A href="{{=URL(r=request, c='books', f='borrow', args=[myBook.books.id])}}">Request This Book</A>
<div><B>Author:</B> {{=myBook.books.author}}</div>
<BR/>
<div align="right"><img height="100" width="80" src="{{=URL(r=request, f="photo", args=[myBook.books.id])}}" /></div>
<div><B>Description:</B> {{=myBook.books.description}}</div>
<BR/>
<div><B>ISBN:</B> {{=myBook.books.ISBN}}</div>
<BR/>
<div><B>Book Owner:</B> {{=myBook.users.username}}</div>
<BR/><BR/>
{{if requests:}}
<h1>Requests Queue</h1>
{{pass}}
<!-- Requested By -->
{{i = 0}}
{{for myRequest in requests:}}
{{if i % 2:}}
<table style="border-width:1px;background-color:silver">
{{else:}}
<table style="border-collapse: collapse; border-width:1px">
{{pass}}
{{ i += 1 }}
<tr><td colspan="2"><div>{{=myRequest.users.first_name}} {{=myRequest.users.last_name}} ({{=myRequest.users.username}})</div></td></tr>
<tr><td><img height="100" width="80" src="{{=URL(r=request, c='users', f='avatar', args=[myRequest.users.id])}}" /></td>
<td><div><b>Requested On:</b> {{=myRequest.readRequests.requestedOn}}</div></td></tr>
</table>
{{pass}}
{{pass}}
